import Qt 4.7

Dialog {
    id: window

    property color fillColor: colors[0]

    property variant colors: ["red","blue","yellow","green",
                              "brown","orange","magenta","purple",
                              "aqua","crimson","darkorchid","lime",
                              "darkgreen","lightblue","pink","white"]

    Grid {
        id: colorGrid
        columns: 4
        anchors.fill: parent
        spacing: 10

        Repeater {
            model: 16

            Rectangle {
                width: (colorGrid.width / colorGrid.columns) - (colorGrid.spacing-3)
                height: (colorGrid.height / colorGrid.columns) - (colorGrid.spacing-3)
                color: chooserArea.pressed ? Qt.darker(colors[index]) : colors[index]
                radius: 5

                MouseArea {
                    id: chooserArea
                    anchors.fill: parent
                    onClicked: {
                        window.fillColor = colors[index]
                        hide()
                    }
                }
            }
        }
    }
}
